<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Pacifico&display=swap"
          rel="stylesheet">

    <title>动态祝福语打字效果</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: gray;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
        }

        .greeting-card {
            background-color: black;
            /*background-image: url("img/bg.png") ;*/
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            padding: 30px;
            min-height: 400px;
            width: 100%;
            text-align: center;
            box-sizing: border-box;
        }

        #typewriter {
            text-align: left;
            font-size: 2rem;
            min-height: 3rem;
            color: #ffffff;
            font-weight: bold;
            white-space: nowrap;
            overflow: hidden;
            font-family: 'Pacifico', cursive;
            /*border-right: 3px solid #e63946;*/
        }

        #language {
            font-style: italic;
            color: #6c757d;
            margin-bottom: 20px;
        }

        button {
            background-color: #e63946;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1rem;
            transition: background-color 0.3s;
        }

        button:hover {
            background-color: #c1121f;
        }

        @media (max-width: 600px) {
            #typewriter {
                font-size: 1.5rem;
            }
        }

        @font-face {
            font-family: 'Maobi';
            src: url('fonts/Maobi.ttf') format('truetype');
        }

        .brush-font {

        }

        .simulated-round {
            text-align: left;
            width: 100%;
            font-family: 'Pacifico', cursive;
            font-size: 3rem;
            color: #ffffff;
            text-shadow: 1px 1px 0px #8B4513,
            2px 2px 3px rgba(139, 69, 19, 0.3);
            display: inline-block;
        }

    </style>
    <style>
        .slide-in-container {
            width: 100%;
            position: relative;
        }

        .slide-in-box {
            position: absolute;
            right: -250px;
            opacity: 0;
            /* 动画配置 */
            animation: slideInFromRight 1s ease-out forwards;
        }

        /* 延迟动画 */
        .delay-1 {
            animation-delay: 0.5s;
        }

        .delay-2 {
            animation-delay: 1s;
        }

        @keyframes slideInFromRight {
            from {
                right: -250px;
                opacity: 0;
            }
            to {
                right: 0;
                opacity: 1;
            }
        }

        /* 带弹跳效果的变体 */
        .bounce-in-box {
            animation: slideInWithBounce 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
        }

        @keyframes slideInWithBounce {
            0% {
                right: -250px;
                opacity: 0;
            }

            25% {
                right: 100px;
                opacity: 1;
            }

            50% {
                right: -100px;
                opacity: 1;
            }

            70% {
                right: 100px;
                opacity: 1;
            }

            85% {
                right: -100px;
                opacity: 1;
            }
            100% {
                right: 0;
                opacity: 1;
            }
        }
    </style>
</head>
<body style="position: relative">
<div class="greeting-card slide-in-box bounce-in-box  delay-2">
    <div class="simulated-round">姚春和 , 祝 :</div>
    <p id="language"></p>
    <div id="typewriter" style="text-indent:2em;white-space: break-spaces;">
    </div>
</div>
<script>
    const greetings = [
        {
            text: '春风化雨润心田 , 岁月静好共光辉 。 愿你的每一天都充满阳光和欢笑 , 每一个梦想都能实现得淋漓尽致 。 祝福你前程似锦 , 万事如意 ! ',
            lang: "English"
        },
        {
            text: "祝福如春雨 , 滋润心田间。愿你笑容常开 , 生活美满甜 ; 事业步步高 , 前程似锦绣。健康快乐伴你左右 , 幸福永远与你相伴!",
            lang: "中文"
        },
        {
            text: "祝福如春风般温暖 , 如夏雨般滋润 , 如秋月般皎洁 , 如冬雪般纯净 。 愿你的每一天都充满阳光和欢笑 , 每一步都走向成功和幸福!",
            lang: "French"
        },
        {
            text: "一份真挚的祝福 , 一份温暖的问候 , 愿你的生活充满阳光和温馨 , 愿你的每一天都过得充实而快乐。 祝福你 , 好运永伴!",
            lang: "German"
        },
        {
            text: "愿你笑口常开 , 福星高照 ; 愿你梦想成真 , 前程似锦 ; 愿你岁岁平安 , 年年有余。祝福你 , 吉祥如意 , 幸福安康!",
            lang: "Spanish"
        }
    ];

    function typingEffect(elementId, text, speed) {
        const element = document.getElementById(elementId);
        let i = 0;
        element.innerHTML = '';

        function type() {
            // if (i!= 0 && i % 20 == 0) {
            //     element.innerHTML += '<br>'
            // }
            if (i < text.length) {
                // element.innerHTML = element.innerHTML.slice(0, element.innerHTML.length - 1)
                if (i % 2 == 0) {
                    element.innerHTML += text.charAt(i) + '|';
                } else {
                    element.innerHTML = element.innerHTML.slice(0, element.innerHTML.length - 1)
                    element.innerHTML += text.charAt(i);
                }
                i++;
                setTimeout(type, speed);
            } else {
                if (element.innerHTML.endsWith("|")) {
                    element.innerHTML = element.innerHTML.slice(0, element.innerHTML.length - 1)
                }
            }
        }

        type();
    }

    function showRandomGreeting() {
        const randomIndex = Math.floor(Math.random() * greetings.length);
        const greeting = greetings[randomIndex];
        typingEffect('typewriter', greeting.text, 200 + Math.random() * 50);
    }

    document.addEventListener('DOMContentLoaded', showRandomGreeting);
</script>
</body>
</html>